import java.util.Map.Entry;

public class HashTableEntry<K,V> implements Entry<K, V> {
	private K key;
	private V value;
	private boolean isAvailable;
	
	public HashTableEntry(K key, V value){
		this.key=key;
		this.value=value;
		this.isAvailable=false;
		
		
		
		if(key==null){
			throw new NullPointerException("Key Can't be a null!");
		}
	}
	
	public boolean isAvailable(){
		return isAvailable;
	}
	
	public void setAvailable(boolean isAvailable){
		this.isAvailable=isAvailable;	
	}

	
	@Override
	public K getKey() {
		return key;
	}

	@Override
	public V getValue() {
		return value;
	}

	@Override
	public V setValue(V value) {
		V tempValue=this.value;
		this.value=value;
		return tempValue;
		
	}
	
	@Override
	public int hashCode(){
		return (getKey()==null   ? 0 : getKey().hashCode()) ^ (getValue()==null ? 0 : getValue().hashCode());
	}
	
	@Override
	public boolean equals(Object o) {
		
		HashTableEntry<K,V> e2 = (HashTableEntry<K,V>) o;
		if(!(o instanceof HashTableEntry)){
			return false;
		} //instance of
		
		return (getKey()==null ? e2.getKey()==null : getKey().equals(e2.getKey()))  &&
			     (getValue()==null ? e2.getValue()==null : getValue().equals(e2.getValue()));
			      
	} //end equals
}